<template>
	<view class="articleItem">
		<view class="headImgView" @click.stop="headImgAction">
			<u-image width="100rpx" height="100rpx" radius='50rpx' :src="item.userModel.avatarUrl" mode="aspectFill" v-if='item.userModel.avatarUrl'></u-image>
		</view>
		<view class="main">
			<view class="nickName limitLineNumOfOne">
				<text>{{item.userModel.nickname?item.userModel.nickname:'昵称未设置'}}</text>
			</view>
			<view class="createTime">{{formatTime(item.createTime)}}</view>
			<view class="content">{{ item.content }}</view>
			<view class="photoList" v-if="item.photoList.length>0">
				<view style='margin-right: 16rpx;margin-bottom: 16rpx;' v-for='(item, index) in item.photoList' :key='index'>
					<u-image width="174rpx" height="174rpx" :src="item.url" mode="aspectFill"></u-image>
				</view>
			</view>
			<view class="footer">
				<view class="btn" @click="heart(index)" v-if="item.isHeart">
					<u-icon name="heart" color="#e66e8e" size="40rpx"></u-icon>
					<text style="margin-left: 12rpx;color: #333;">{{item.heartNums}}</text>
				</view>
				<view class="btn" @click="heart(index)" v-else>
					<u-icon name="heart" color="#666" size="40rpx"></u-icon>
					<text style="margin-left: 12rpx;color: #666;">{{item.heartNums}}</text>
				</view>
				<!-- <view class="btn">
					<u-icon name="chat" color="#666" size="40rpx"></u-icon>
					<text style="margin-left: 12rpx;color: #666;">0</text>
				</view> -->
			</view>
		</view>
	</view>
</template>

<script>
	import {upload_baseUrl} from '@/api/baseUrl.js'
	export default {
		props: {
			item: {
				type: Object,
				dafault: {}
			},
			index: {
				type: String,
				default: ''
			}
		},
		data() {
			return {
				upload_baseUrl: upload_baseUrl,
			}
		},
		methods: {
			formatTime(time){
				return this.$time.formatTime(time)
			},
			heart(index){
				this.$emit('heart', index)
			},
			headImgAction(){
				this.$emit('headImgAction', this.item.userModel)
			},
		}
	}
</script>

<style lang="scss" scoped>
	.articleItem{
		display: flex;
		flex-direction: row;
		padding: 0 30rpx;
		margin-top: 30rpx;
		border-bottom: 1rpx solid #eeeeee;
		.headImgView{
		}
		.main{
			display: flex;
			flex-direction: column;
			width: 570rpx;
			margin-left: 20rpx;
			// margin: 0 16rpx;
			.nickName{
				font-size: 30rpx;
				color: #333;
				font-weight: bold;
			}
			.createTime{
				font-size: 24rpx;
				color: #999999;
			}
			.content{
				margin-top: 16rpx;
				font-size: 30rpx;
				color: #666666;
			}
			.photoList{
				margin-top: 20rpx;
				display: flex;
				flex-direction: row;
				flex-wrap: wrap;
			}
			.footer{
				display: flex;
				flex-direction: row;
				align-items: center;
				justify-content: flex-end;
				margin: 20rpx 0;
				.btn{
					display: flex;
					flex-direction: row;
					align-items: center;
					margin-left: 60rpx;
				}
			}
		}
	}
</style>
